<?php

final class notification {
	
	/**
	 * The allowed notification types
	 */
	private $allowed_types = array('error', 'info', 'success', 'warning');
	
	/**
	 * The notification type
	 */
	private $type;
	
	/**
	 * The notification message
	 */
	private $message;
	
	/**
	 * Constructor
	 */
	public function __construct($notification) {
		$this->type = $notification['type'];
		$this->message = $notification['message'];
		
		call_user_func(array($this, $notification['func']));
	}
	
	/**
	 * Function to show the message
	 */
	public function show_message() {
		if(!in_array($this->type, $this->allowed_types))
			return false;
	
		switch($this->type):
			
			case 'success':
				$notification_class = 'alert-success';
				break;
			
			case 'info':
				$notification_class = 'alert-info';
				break;
				
			case 'error':
				$notification_class = 'alert-error';
				break;
				
			case 'warning':
				$notification_class = 'alert';
				break;
			
		endswitch;
		
		// echo the notification
		echo "<div class=\"alert $notification_class\">$this->message</div>";
	}
	
}